package cn.edu.scnu.movies.controller;

import cn.edu.scnu.movies.entity.PageResult;
import cn.edu.scnu.movies.entity.QueryString;
import cn.edu.scnu.movies.entity.Result;
import cn.edu.scnu.movies.entity.movies;
import cn.edu.scnu.movies.service.MoviesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api/rank")
@RestController
public class MoviesController {

    @Autowired
    private MoviesService moviesService;
    @GetMapping("/all")
    public Result getHotMovies(QueryString queryString){
        PageResult<movies> movies = moviesService.getHotMovies(queryString);
        return Result.success(movies);
    }

    /**
     * 获取好评排行榜
     */
    @GetMapping("/rating")
    public Result getRatingRank(QueryString queryString) {
        PageResult<movies> movies = moviesService.getRatingRank(queryString);
        return Result.success(movies);
    }

    /**
     * 获取本周排行耪
     */
    @GetMapping("/week")
    public Result getWeekRank(QueryString queryString) {
        PageResult<movies> movies = moviesService.getWeekRank(queryString);
        return Result.success(movies);
    }

    /**
     * 获取本月排行耪
     */
    @GetMapping("/month")
    public Result getMonthRank(QueryString queryString) {
        PageResult<movies> movies = moviesService.getMonthRank(queryString);
        return Result.success(movies);
    }
}